
package JET.physics.bodies;

import JET.geom.Vec2d;
import JET.physics.Wall;
import java.util.ArrayList;

/**
 *
 * @author raos
 */
public class RigidBodyFactory {
    public static RigidBody buildRect(double x1, double y1, double x2, double y2, double mass) {
        RigidBody rb = new RigidBody();

        ArrayList<Vec2d> vecs = new ArrayList<Vec2d>();
        vecs.add(new Vec2d(x1,y1));
        vecs.add(new Vec2d(x2,y1));
        vecs.add(new Vec2d(x2,y2));
        vecs.add(new Vec2d(x1,y2));


        rb.buildBaseShape(vecs, mass);

        rb.border.addWall(new Wall(rb.getDynVecList().get(0),
                                   rb.getDynVecList().get(1)));
        rb.border.addWall(new Wall(rb.getDynVecList().get(1), 
                                   rb.getDynVecList().get(2)));
        rb.border.addWall(new Wall(rb.getDynVecList().get(2),
                                   rb.getDynVecList().get(3)));
        rb.border.addWall(new Wall(rb.getDynVecList().get(3),
                                   rb.getDynVecList().get(0)));
        return rb;
    }
}
